#include "TreeItem_Chapter.h"
#include "Common.h"

namespace Jonathan
{

   /**
    * @brief Initializes a new chapter tree item.
    *
    * @param chapter Chapter.
    * @param parent Parent tree item.
    */
   TreeItem_Chapter::TreeItem_Chapter (int chapter, QTreeWidgetItem *parent) :
      IBookListItem (parent), m_Chapter (chapter)
   {
      this->m_Type = Jonathan::Chapter;
      this->setText (0, QString::number (chapter));
      this->setIcon (0, Common::GetIcon (ICON_Chapter));
   }

   /**
    * @brief Initializes a new preface tree item.
    *
    * @param parent Parent tree item.
    */
   TreeItem_Chapter::TreeItem_Chapter (QTreeWidgetItem *parent) :
      IBookListItem (parent)
   {
      this->m_Type = Jonathan::Preface;
      this->setText (0, Common::PREFACE);
      this->setIcon (0, Common::GetIcon (ICON_Chapter));
   }

   /**
    * @brief Gets the name of the chapter.
    *
    * @return QString Name of the Chapter.
    */
   QString TreeItem_Chapter::GetName ()
   {
      if (this->m_Type == Jonathan::Preface)
         return Common::PREFACE;

      return QString::number (this->m_Chapter);
   }

}
